apache redirection does not work

apache redirection does not work

am 01.10.2009 17:53:15 von Sharjeel Tariq

--0016e646926a379c440474e1a552
Content-Type: text/plain; charset=ISO-8859-1

Hi,


I am trying to set up apache redirection rule for redirecting all of our non
'www' domains to 'www' domains. I got the redirection rule from apache
manual
but the rule does not work when we have subdirectories and parameters at the
end of url.

The redirection rule i have is


RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^/(.*)$ http://www.example.com/$1 [L,R]


The above rule works for all urls except when I have urls like

http://example.com/news/headlines/more.jsp?content=20090624_ 075115_6540

Instead of redirecting the above url to

http://www.example.com/news/headlines/more.jsp?content=20090 624_075115_6540

It is redirecting it to home page of site with
"?content=20090624_075115_6540" at the end


http://www.example.com/index.jsp?content=20090624_075115_654 0

I need a generic redirection rule to redirection all non 'www' urls to 'www'
urls. I have to apply this rule on almost 50 web sites.


Thanks,

--0016e646926a379c440474e1a552
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,


I am trying to set up apache redirection rule for redirecti=
ng all of our non
'www' domains to 'www' domains. I got =
the redirection rule from apache manual
but the rule does not work when =
we have subdirectories and parameters at the

end of url.

The redirection rule i have is


RewriteCond %=
{HTTP_HOST} ^$
RewriteRul=
e ^/(.*)$ http://www.example.com/$1 a> [L,R]



The above rule works for all urls except when I have urls like
<=
br>
_075115_6540">http://example.com/news/headlines/more.jsp?con tent=3D20090624=
_075115_6540



Instead of redirecting the above url to

xample.com/news/headlines/more.jsp?content=3D20090624_075115 _6540">http://w=
ww.example.com/news/headlines/more.jsp?content=3D20090624_07 5115_6540
r>

It is redirecting it to home page of site with "?content=3D2009062=
4_075115_6540" at the end


/index.jsp?content=3D20090624_075115_6540">http://www.exampl e.com/index.jsp=
?content=3D20090624_075115_6540



I need a generic redirection rule to redirection all non 'www' =
urls to 'www'
urls. I have to apply this rule on almost 50 web s=
ites.


Thanks,

--0016e646926a379c440474e1a552--

Re: apache redirection does not work

am 01.10.2009 18:37:54 von Bob Ionescu

2009/10/1 Sharjeel Tariq :
> RewriteCond %{HTTP_HOST} ^example.com$
> RewriteRule ^/(.*)$ http://www.example.com/$1 [L,R]
>
>
> The above rule works for all urls except when I have urls like
>
> http://example.com/news/headlines/more.jsp?content=20090624_ 075115_6540
>
> Instead of redirecting the above url to
>
> http://www.example.com/news/headlines/more.jsp?content=20090 624_075115_6540
>
> It is redirecting it to home page of site with
> "?content=20090624_075115_6540" at the end
>
>
> http://www.example.com/index.jsp?content=20090624_075115_654 0

Please enable a RewriteLog with

Rewritelog logs/rewrite_log
Rewriteloglevel 6

in your httpd.conf and post the result (may be as an attachment).

Bob

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: apache redirection does not work

am 01.10.2009 21:21:04 von Jonathan Zuckerman

On Thu, Oct 1, 2009 at 9:37 AM, Bob Ionescu wrot=
e:
> 2009/10/1 Sharjeel Tariq :
>> RewriteCond %{HTTP_HOST} ^example.com$
>> RewriteRule ^/(.*)$ http://www.example.com/$1 [L,R]
>>
>>
>> The above rule works for all urls except when I have urls like
>>
>> http://example.com/news/headlines/more.jsp?content=3D2009062 4_075115_654=
0
>>
>> Instead of redirecting the above url to
>>
>> http://www.example.com/news/headlines/more.jsp?content=3D200 90624_075115=
_6540
>>
>> It is redirecting it to home page of site with
>> "?content=3D20090624_075115_6540" at the end
>>
>>
>> http://www.example.com/index.jsp?content=3D20090624_075115_6 540
>
> Please enable a RewriteLog with
>
> Rewritelog logs/rewrite_log
> Rewriteloglevel 6
>
> in your httpd.conf and post the result (may be as an attachment).
>
> Bob
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project=
..
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.or=
g
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Try adding QSA to the flags at the end of the redirect. (Query-String All)

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: apache redirection does not work

am 01.10.2009 23:06:42 von Martin Spinassi

On Thu, 2009-10-01 at 11:53 -0400, Sharjeel Tariq wrote:
> Hi,
>
>
> I am trying to set up apache redirection rule for redirecting all of
> our non
> 'www' domains to 'www' domains. I got the redirection rule from apache
> manual
> but the rule does not work when we have subdirectories and parameters
> at the
> end of url.
>
> The redirection rule i have is
>
>
> RewriteCond %{HTTP_HOST} ^example.com$
> RewriteRule ^/(.*)$ http://www.example.com/$1 [L,R]
>


Sharjeel,

I know it's not what you are asking for, but may accomplish your task.

You can try adding a ServerAlias to the VirtualHost:

ServerName example.com
ServerAlias www.example.com

Here is the documentation at apache site:
http://httpd.apache.org/docs/2.0/mod/core.html#serveralias


Sorry if it's not what you are asking for, but it's pretty much waht I'd
do. With a simple script you can manage to add the ServerAlias to all
the VirtualHosts.


Cheers,

Martin


------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: apache redirection does not work

am 02.10.2009 16:46:38 von Sharjeel Tariq

--0016e6460848d699720474f4d4fe
Content-Type: text/plain; charset=ISO-8859-1

The issue with creating ServerAlias is we get two analytics reports for each
of our site. There are many benefits associated with redirecting non 'www'
urls to 'www' urls.

I tried using following configuration in httpd.conf as per Bob
recommendation.


Rewritelog logs/rewrite_log
Rewriteloglevel 6


It created file rewrite_log but did not write any thing in the log file. I
have also tried using QSA flag to the rule but that didn't work either.


Thanks,
Sharjeel

On Thu, Oct 1, 2009 at 5:06 PM, Martin Spinassi wrote:

> On Thu, 2009-10-01 at 11:53 -0400, Sharjeel Tariq wrote:
> > Hi,
> >
> >
> > I am trying to set up apache redirection rule for redirecting all of
> > our non
> > 'www' domains to 'www' domains. I got the redirection rule from apache
> > manual
> > but the rule does not work when we have subdirectories and parameters
> > at the
> > end of url.
> >
> > The redirection rule i have is
> >
> >
> > RewriteCond %{HTTP_HOST} ^example.com$
> > RewriteRule ^/(.*)$ http://www.example.com/$1 [L,R]
> >
>
>
> Sharjeel,
>
> I know it's not what you are asking for, but may accomplish your task.
>
> You can try adding a ServerAlias to the VirtualHost:
>
> ServerName example.com
> ServerAlias www.example.com
>
> Here is the documentation at apache site:
> http://httpd.apache.org/docs/2.0/mod/core.html#serveralias
>
>
> Sorry if it's not what you are asking for, but it's pretty much waht I'd
> do. With a simple script you can manage to add the ServerAlias to all
> the VirtualHosts.
>
>
> Cheers,
>
> Martin
>
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--0016e6460848d699720474f4d4fe
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

The issue with creating ServerAlias is we get two analytics reports for eac=
h of our site. There are many benefits associated with redirecting non '=
;www' urls to 'www' urls.

I tried using following confi=
guration in httpd.conf as per Bob recommendation.




Rewritelog logs/rewrite_log

Rewriteloglevel 6


It created file rewrite_log but did not write=
any thing in the log file. I have also tried using QSA flag to the rule bu=
t that didn't work either.



Thanks,
Sharjeel

On Thu, Oct 1=
, 2009 at 5:06 PM, Martin Spinassi < martins.listz@gmail.com" target=3D"_blank">martins.listz@gmail.com><=
/span> wrote:

204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, 2009-10-01 at 11:53 -0400, Sharjeel Tariq wrote:

> Hi,

>

>

> I am trying to set up apache redirection rule for redirecting all of r>
> our non

> 'www' domains to 'www' domains. I got the redirection =
rule from apache

> manual

> but the rule does not work when we have subdirectories and parameters<=
br>
> at the

> end of url.

>

> The redirection rule i have is

>

>

> RewriteCond %{HTTP_HOST} ^ ank">example.com$

> RewriteRule ^/(.*)$ lank">http://www.example.com/$1 [L,R]

>

<snip>



Sharjeel,



I know it's not what you are asking for, but may accomplish your task.<=
br>


You can try adding a ServerAlias to the VirtualHost:



ServerName =


ServerAlias www.exampl=
e.com




Here is the documentation at apache site:

et=3D"_blank">http://httpd.apache.org/docs/2.0/mod/core.html #serveralias >





Sorry if it's not what you are asking for, but it's pretty much wah=
t I'd

do. With a simple script you can manage to add the ServerAlias to all

the VirtualHosts.





Cheers,



Martin




--0016e6460848d699720474f4d4fe--

Re: apache redirection does not work

am 02.10.2009 17:23:15 von Eric Covener

On Fri, Oct 2, 2009 at 10:46 AM, Sharjeel Tariq
wrote:
> The issue with creating ServerAlias is we get two analytics reports for each
> of our site. There are many benefits associated with redirecting non 'www'
> urls to 'www' urls.
>
> I tried using following configuration in httpd.conf as per Bob
> recommendation.
>
>
> Rewritelog logs/rewrite_log
> Rewriteloglevel 6
>
>
> It created file rewrite_log but did not write any thing in the log file. I
> have also tried using QSA flag to the rule but that didn't work either.

no RewriteEngine on, htaccess not being read (allowoverride?), or
rules in a that isn't actually handling the request?

--
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: apache redirection does not work

am 02.10.2009 21:48:40 von Sharjeel Tariq

--0016e64719b0fad22a0474f90c6c
Content-Type: text/plain; charset=ISO-8859-1

rewriteEngine is on. Here is the rule in Virtual Host.


Servername www.example.com
DocumentRoot /www/www_example_com/
CustomLog /var/log/apache/www_example_com_access.log
combined env=!disable_logging
ErrorLog /var/log/apache/www_example_com_error.log
include conf/shared/blockWebInf.inc
CookieDomain .example.com
WLCookieName visunique
CookieTracking on
RewriteEngine On
RewriteRule ^/(.*\.jsp.*$|.*\/$|$)
http://localhost:6201/www_example_com/$1 [P]
ProxyPassReverse / http://localhost:6201/www_example_com



Can I say this is a bug in apache as I got this redirction rule from apache
manual to redirect all non 'www' requests to 'www' requests but it seems as
apache is not handling the urls with parameter at the end?



On Fri, Oct 2, 2009 at 11:23 AM, Eric Covener wrote:

> On Fri, Oct 2, 2009 at 10:46 AM, Sharjeel Tariq
> wrote:
> > The issue with creating ServerAlias is we get two analytics reports for
> each
> > of our site. There are many benefits associated with redirecting non
> 'www'
> > urls to 'www' urls.
> >
> > I tried using following configuration in httpd.conf as per Bob
> > recommendation.
> >
> >
> > Rewritelog logs/rewrite_log
> > Rewriteloglevel 6
> >
> >
> > It created file rewrite_log but did not write any thing in the log file.
> I
> > have also tried using QSA flag to the rule but that didn't work either.
>
> no RewriteEngine on, htaccess not being read (allowoverride?), or
> rules in a that isn't actually handling the request?
>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--0016e64719b0fad22a0474f90c6c
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

rewriteEngine is on. Here is the rule in Virtual Host.

<VirtualHo=
st *>
     Servername www.=
example.com

     DocumentRoot /www/www_example_com/
=A0=
              =A0 CustomLog /var/log/apache/www=
_example_com_access.log combined env=3D!disable_logging

                 ErrorLog /var/log/apache/w=
ww_example_com_error.log
              =A0=
=A0 include conf/shared/blockWebInf.inc
          =
       CookieDomain .example.com=

                 WLCookieName visun=
ique

                 CookieTracking on
=A0=
  =A0 RewriteEngine On
     RewriteRule ^/(.*\.jsp.*$|.*\/$|=
$) http://localhost:62=
01/www_example_com/$1
[P]
     ProxyPassReverse / "http://localhost:6201/www_example_com">http://localhost:620 1/www_example_c=
om


</VirtualHost>


Can I say this is a bug in apache as I got =
this redirction rule from apache manual to redirect all non 'www' r=
equests to 'www' requests but it seems as apache is not handling th=
e urls with parameter at the end?




On Fri, Oct 2, 2009 at 11:23 AM, Eri=
c Covener < =3D"_blank">covener@gmail.com> wrote:
"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0=
pt 0pt 0pt 0.8ex; padding-left: 1ex;">

On Fri, Oct 2, 2009 at 10:46 AM, Sharjeel Tariq

<sharjeel=
..tariq1@gmail.com
> wrote:

> The issue with creating ServerAlias is we get two analytics reports fo=
r each

> of our site. There are many benefits associated with redirecting non &=
#39;www'

> urls to 'www' urls.

>

> I tried using following configuration in httpd.conf as per Bob

> recommendation.

>

>

> Rewritelog logs/rewrite_log

> Rewriteloglevel 6

>

>

> It created file rewrite_log but did not write any thing in the log fil=
e. I

> have also tried using QSA flag to the rule but that didn't work ei=
ther.



no RewriteEngine on, htaccess not being read (allowoverride?), or

rules in a =A0<virtualHost> that isn't actually handling the requ=
est?



--

Eric Covener

covener@gmail.com >




--0016e64719b0fad22a0474f90c6c--

Re: apache redirection does not work

am 02.10.2009 21:59:54 von Eric Covener

On Fri, Oct 2, 2009 at 3:48 PM, Sharjeel Tariq
wrote:
> rewriteEngine is on. Here is the rule in Virtual Host.
>
>
>      Servername www.example.com
>      DocumentRoot /www/www_example_com/
>                  CustomLog /var/log/apach=
e/www_example_com_access.log
> combined env=3D!disable_logging
>                  ErrorLog /var/log/apache=
/www_example_com_error.log
>                  include conf/shared/bloc=
kWebInf.inc
>                  CookieDomain .example.co=
m
>                  WLCookieName visunique
>                  CookieTracking on
>      RewriteEngine On
>      RewriteRule ^/(.*\.jsp.*$|.*\/$|$)
> http://localhost:6201/www_example_com/$1 [P]
>      ProxyPassReverse / http://localhost:6201/www_example_com
>

>
>
> Can I say this is a bug in apache as I got this redirction rule from apac=
he
> manual to redirect all non 'www' requests to 'www' requests but it seems =
as
> apache is not handling the urls with parameter at the end?

Did you paste the right snippet? That's a pretty elaborate regex, and
doesn't redirect at all but proxies.

--=20
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org

Re: apache redirection does not work

am 02.10.2009 22:07:03 von Sharjeel Tariq

--00151773e730c0f80a0474f94e6f
Content-Type: text/plain; charset=ISO-8859-1

the redirection rule is written in a separate file under .


RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^/(.*)$ http://www.example.com/$1 [L,R]


The issue was that above rule works for all urls except for urls like
http://example.com/news/headlines/more.jsp?content=20090624_ 075115_6540


the rule redirects the above url to home page of site

http://www.example.com/index.jsp?content=20090624_075115_654 0


Thanks,
Sharjeel.

On Fri, Oct 2, 2009 at 3:59 PM, Eric Covener wrote:

> On Fri, Oct 2, 2009 at 3:48 PM, Sharjeel Tariq
> wrote:
> > rewriteEngine is on. Here is the rule in Virtual Host.
> >
> >
> > Servername www.example.com
> > DocumentRoot /www/www_example_com/
> > CustomLog /var/log/apache/www_example_com_access.log
> > combined env=!disable_logging
> > ErrorLog /var/log/apache/www_example_com_error.log
> > include conf/shared/blockWebInf.inc
> > CookieDomain .example.com
> > WLCookieName visunique
> > CookieTracking on
> > RewriteEngine On
> > RewriteRule ^/(.*\.jsp.*$|.*\/$|$)
> > http://localhost:6201/www_example_com/$1 [P]
> > ProxyPassReverse / http://localhost:6201/www_example_com
> >

> >
> >
> > Can I say this is a bug in apache as I got this redirction rule from
> apache
> > manual to redirect all non 'www' requests to 'www' requests but it seems
> as
> > apache is not handling the urls with parameter at the end?
>
> Did you paste the right snippet? That's a pretty elaborate regex, and
> doesn't redirect at all but proxies.
>
> --
> Eric Covener
> covener@gmail.com
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

--00151773e730c0f80a0474f94e6f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

=A0the redirection rule is written in a separate file under <VirtualHost=
*>.


RewriteCond %{HTTP_HOST} ^ " target=3D"_blank">example.com$
RewriteRule ^/(.*)$ p://www.example.com/$1" target=3D"_blank">http://www.example.com/$1 [L,=
R]



The issue was that above rule works for all urls except for urls li=
ke _075115_6540" target=3D"_blank">http://example.com/news/headlines/more.jsp ?=
content=3D20090624_075115_6540




the rule redirects the above url to home page of site

f=3D"http://www.example.com/index.jsp?content=3D20090624_075 115_6540" targe=
t=3D"_blank">http://www.example.com/index.jsp?content=3D2009 0624_075115_654=
0




Thanks,
Sharjeel.

On Fri, Oct =
2, 2009 at 3:59 PM, Eric Covener < vener@gmail.com">covener@gmail.com> wrote:
ss=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, 204, 204); marg=
in: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Fri, Oct 2, 2009 at 3:48 PM, Sharjeel Tariq

> rewriteEngine is on. Here is the rule in Virtu=
al Host.

>

> <VirtualHost *>

>      Servername blank">www.example.com

>      DocumentRoot /www/www_example_com/

>                  CustomLog /var/log/ap=
ache/www_example_com_access.log

> combined env=3D!disable_logging

>                  ErrorLog /var/log/apa=
che/www_example_com_error.log

>                  include conf/shared/b=
lockWebInf.inc

>                  CookieDomain . =3D"http://example.com" target=3D"_blank">example.com

>                  WLCookieName visuniqu=
e

>                  CookieTracking on

>      RewriteEngine On

>      RewriteRule ^/(.*\.jsp.*$|.*\/$|$)

> >http://localhost:6201/www_example_com/$1 [P]

>      ProxyPassReverse / xample_com" target=3D"_blank">http://localhost:6201/www_example_com

> </VirtualHost>

>

>

> Can I say this is a bug in apache as I got this redirction rule from a=
pache

> manual to redirect all non 'www' requests to 'www' req=
uests but it seems as

> apache is not handling the urls with parameter at the end?



Did you paste the right snippet? That's a pretty elaborate regex,=
and

doesn't redirect at all but proxies.



--

Eric Covener





------------------------------------------------------------ ---------

The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL: lank">http://httpd.apache.org/userslist.html> for more info.

To unsubscribe, e-mail: g">users-unsubscribe@httpd.apache.org

=A0 " =A0 from the digest: @httpd.apache.org">users-digest-unsubscribe@httpd.apache.org

For additional commands, e-mail: org">users-help@httpd.apache.org






--00151773e730c0f80a0474f94e6f--

Re: apache redirection does not work

am 02.10.2009 22:14:25 von Eric Covener

On Fri, Oct 2, 2009 at 4:07 PM, Sharjeel Tariq
wrote:
> =A0the redirection rule is written in a separate file under *>.
>
>
> RewriteCond %{HTTP_HOST} ^example.com$
> RewriteRule ^/(.*)$ http://www.example.com/$1 [L,R]
>
>
> The issue was that above rule works for all urls except for urls like
> http://example.com/news/headlines/more.jsp?content=3D2009062 4_075115_6540
>
>
> the rule redirects the above url to home page of site
>
> http://www.example.com/index.jsp?content=3D20090624_075115_6 540

And it can't be captured by a RewriteLog? Is it some other
rewrite/redirect occuring?

--=20
Eric Covener
covener@gmail.com

------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org